package org.tgcloud.group.service.manager.project;

import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.tgcloud.group.core.APPResultMessage;
import org.tgcloud.group.core.ResultMessage;
import org.tgcloud.group.entity.MjProjectStage;
import org.tgcloud.group.entity.ProjectMediaRequirements;
import org.tgcloud.group.repository.MjProjectStageMapper;
import org.tgcloud.group.repository.ProjectMediaRequirementsMapper;
import org.tgcloud.group.web.controller.dto.project.ProjectStageDto;

import javax.transaction.Transactional;
import java.util.List;

@Service
public class ProjectStageService extends ServiceImpl<MjProjectStageMapper, MjProjectStage> {

    @Autowired
    private MjProjectStageMapper mjProjectStageMapper;

    public APPResultMessage queryStage(ProjectStageDto projectStageDto) {
        LambdaQueryWrapper<MjProjectStage> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.orderByAsc(MjProjectStage::getSort);
        queryWrapper.eq(ObjectUtils.isNotEmpty(projectStageDto.getProjectId()),MjProjectStage::getProjectId, projectStageDto.getProjectId());
        queryWrapper.like(ObjectUtils.isNotEmpty(projectStageDto.getKeyword()),MjProjectStage::getName, projectStageDto.getKeyword());
        if(ObjectUtils.isNotEmpty(projectStageDto.getPageNum()) && projectStageDto.getPageSize() != null){}
        List<MjProjectStage> projectStages = mjProjectStageMapper.selectList(queryWrapper);
        APPResultMessage<Object, MjProjectStage> message = APPResultMessage.getSuccessMessage();
        ResultMessage result = ResultMessage.builder()
                .setList(projectStages)
                .setCount(projectStages.size());
        message.setResult(result);
        return message;
    }


}
